<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page errorPage="/dorado/exception.d" %>
<%@ taglib uri="http://www.bstek.com/dorado" prefix="d" %>
<%@page import="java.util.*"%>
<%@page import="com.xr.common.Tools"%>
<html>
<head>
<title>薪资接口数据导入</title>
</head>
<body>

<script language="javascript">
 function doSub(){
 
  if(datasetSend.getCurrent()==null){
      alert('请选择上面的表格的发放记录！');
      return;
  }
    if(form1.file.value==''){
      alert('请上传Excel文件！');
      return;
    }
 
   if(document.getElementById("file").value.split('.xls')[1]!='' && document.getElementById("file").value.split('.xlsx')[1]!=''){
      alert("导入的文件要求是excel文件"); 
      return false;
    }
    if(confirm('发放名称：'+datasetSend.getValue('SEND_NAME')+' 发放月：'+datasetSend.getValue('SEND_MONTH')+'  您确定要上传并导入数据吗？')){
     form1.oldfilename.value=form1.file.value;
     form1.SEND_ID.value=datasetSend.getValue('SEND_ID');
      document.getElementById("buttonSubmit").disabled=true;
     form1.submit();
     
     }
 }
 function getFileSize(filePath)   
{ 
   /*
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   if(fso.GetFile(filePath).size>2000000){
    document.getElementById("file").value="";
    document.getElementById("file").outerHTML=document.getElementById("file").outerHTML; 
    alert("文件不能超过2M");
    }
    */
    if(document.getElementById("file").value.split('.xls')[1]!='' && document.getElementById("file").value.split('.xlsx')[1]!=''){
      alert("导入的文件要求是excel文件。"); 
    }
   
}   
function checkboxonclick(){
if(document.getElementById("IF_COVER").value==1){
  document.getElementById("IF_COVER").value=0;
}else{
   document.getElementById("IF_COVER").value=1;
}
}
</script>
  <d:View config="com.xr.wage.dataInterface.dataImport">
  <%
 
    String impInterfaceId=Tools.toStr(request.getParameter("IMP_INTERFACE_ID"));
    String writeback=Tools.toStr(request.getParameter("writeback"));   
    String catalog=Tools.toStr(request.getParameter("catalog")); 
    String writebackFullNewName=Tools.toStr(request.getParameter("writebackFullNewName"));
%>
  <d:Layout type="vflow">
 
    <d:Pane>
     <d:DataTable id="table1" />
    </d:Pane>
  </d:Layout> 
    <d:SubWindow id="winClass" title="薪资类别人数汇总" width="350" height="250" draggable="true" resizable="false" status="hidden"  showMinimizeButton="false" showMaximizeButton="false" showCloseButton="true">
   <d:DataTable id="tableClass" />
<!--   <d:StaticTable id="tableClass" />-->
   </d:SubWindow>
    
    
    <center>    
      <form method="post" name="form1" enctype="multipart/form-data"
        action="<%=request.getContextPath()%>/payroll/dataImport.upload.d">       
<%      
String oldFileName = (String)request.getAttribute("old_name");          
String upload_result = (String)request.getAttribute("upload_result");
if (upload_result != null) { 
  
%>
    <input type="hidden" name="oldfilename" value="<%=oldFileName%>">
    <script language="javascript">     
      <%
      String back=(String)request.getAttribute("write_back"); 
      if(back.equals("1")){
      %>   
         parent.writeBackFileName(document.form1.oldfilename.value);
    <%
      }  
      String backFullNewName=(String)request.getAttribute("write_back_full_new_name");       
      if(Tools.toStr(backFullNewName).equals("1")){
         String fullNewName=(String)request.getAttribute("full_new_name");
     %>
          parent.writeBackFullNewName('<%=fullNewName%>');
    <%
      }
    %> 
      try{        
         SubWindow.hideParent();
      }catch (theException) {
          alert("ddd");
      } finally {
         alert("文件上传成功！");
      }
       
      
    </script>  
<%
}
else {
%>     
        <input type="hidden" name="IMP_INTERFACE_ID" value="<%=impInterfaceId%>"/>
        <input type="hidden" name="SEND_ID" value=""/>
        <input type="hidden" name="writeback" value="<%=writeback%>"/> 
        <input type="hidden" name="oldfilename" value=""/>   
        <input type="hidden" name="catalog" value="<%=catalog%>"/>
        <input type="hidden" name="writebackFullNewName" value="<%=writebackFullNewName%>"/>
        
        <d:Layout type="vflow" width="90%">
         
          <d:Pane valign="middle" height="30">
            请选择要上传的excel数据文件:&nbsp;&nbsp; &nbsp;
            <select name="COVER_STATUS" value="1">
            <option value="1">强制覆盖原有的数据</option>
            <option value="0">如有数字，不覆盖导入</option>
            <option value="2">如原有的数字大于零，相加导入</option>
            </select>
             <input class="TextEditor" type="file" id='file' name="file" onchange="getFileSize(this.value);"  style="width: 100%">
          </d:Pane>
          <d:Pane align="center">
          
            <input class="Button" type="button" id='buttonSubmit' value=" 上传数据并导入 " onclick="doSub()">&nbsp;&nbsp;&nbsp;
             <input class="Button" type="button" value=" 关闭 " onclick="SubWindow.hideParent()">
          </d:Pane>
        </d:Layout>
     
<%
}
%>    
 </form>
</center> 
    
    
  </d:View>
</body>
</html>
